home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
autolib.exe
/
EX02.EXE
/
WYSE.C
< prev
next >
Wrap
Text File
|
1992-02-16
|
7KB
|
241 lines
/* wyse.c */
#include <stdio.h>
#include <stdlib.h>
#include <alloc.h>
#include <string.h>
#include <time.h>
#include <dir.h>
/* AutoLibrary by Avid Software */
#include "al.h"
#include "wyse.h"
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/*******************/
void clear_wyse_screen(com)
int com;
/*******************/
{
char temp_buf[85];
int err, info;
sprintf(temp_buf, "%s*", ESC_CODE);
if ((err = AvidSend(AVID, com, temp_buf, &info, "")) != ERR_SNF)
AvidLogInfo(AVID, com, "Problem clearing screen", err, &info, "*ETL");
}
/*******************/
void initialize_testing(com)
int com;
/*******************/
{
char temp_buf[85];
int err, info;
/* Before even trying the tests make sure things are cabled
correctly and we are connected to a Wyse 50 or Wyse 30 terminal.
Use the command ESC space
Where:
space is a blank space.
The Wyse terminal will return 50\r, 30\r or 60\r
*/
sprintf(temp_buf, ".s'%s ' 1w'50' 2w'30' 3w'60' .d'1'", ESC_CODE);
if ((err = AvidSendSearch(AVID, com, (long)10, (long)30, &info, temp_buf)) <= ERR_SNF)
AvidLogInfo(AVID, com, "Failed to connect", err, &info, "*ETL");
/* Clear the screen. */
clear_wyse_screen(com);
}
/*******************/
char new_char()
/*******************/
{
static char *abc = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
return (abc[random(62)]);
}
/*******************/
void test_protected_mode(com)
int com;
/*******************/
{
int info;
com = com; /* for compiler */
AvidLogInfo(AVID, com, "Executing protected mode tests", 0, &info, "*T");
AvidLogInfo(AVID, com, "Finished", 0, &info, "*T");
}
/*******************/
void test_scr_attribs(com)
int com;
/*******************/
{
int info;
com = com; /* for compiler */
AvidLogInfo(AVID, com, "Executing screen attributes tests", 0, &info, "*T");
AvidLogInfo(AVID, com, "Finished", 0, &info, "*T");
}
/*******************/
void test_scr_loc(com, num_row, num_col)
int com;
int num_row; /* The number of rows to test. */
int num_col; /* The number of columns to test. */
/*******************/
{
int i, j, row, col;
char temp_buf[100];
long actual;
char capture[85];
int err, info;
/*
This will test the following commands...
ESC a rr R ccc C which moves the cursor to a specified
row and column for an 80 or 132 column
screen. ESCa1R1C will position cursor
at home position, for example.
ESC b which transmits the cursor address to the host
computer for the active text segment in the format
rr R ccc C
Where:
rr = the ASCII encoded decimal value of the row
R = ASCII R
ccc = the ASCII encoded decimal value of the column
C = ASCII C
Test Description:
Within a nested for loop the ESC a rr R ccc C command is used
to position the cursor. The ESC b command is then used to
verify that the cursor was moved.
*/
/* Clear the screen. */
clear_wyse_screen(com);
AvidLogInfo(AVID, com, "Executing screen location test", 0, &info, "*T");
/* Shorten the test if requested. */
if ( !long_version)
num_col = 10;
/* Test each screen location. */
for (j=1; j<=num_col; j++) {
for (i=1; i<=num_row; i++) {
/* Move cursor to known location with ESC a rr R ccc C */
sprintf(temp_buf, "%sa%dR%dC", ESC_CODE, i, j);
if ((err = AvidSend(AVID, com, temp_buf, &info, "")) != ERR_SNF)
AvidLogInfo(AVID, com, "Problem sending string", err, &info, "*ETL");
/* Make sure the cursor is where we placed it with ESC b */
sprintf(temp_buf, ".s'%sb' 1w'C' -c'6'", ESC_CODE);
if ((err = AvidSendSearch(AVID, com, (long)10, (long)30, &info, temp_buf, (long *)&actual, capture)) <= ERR_SNF)
AvidLogInfo(AVID, com, "Cursor not placed correctly", err, &info, "*ETL");
/* Get the cursor positions out of the capture string. */
sscanf(capture, "%dR%d", &row, &col);
if (row != i)
AvidLogInfo(AVID, com, "Cursor not placed correctly", row, &info, "*ETL");
if (col != j)
AvidLogInfo(AVID, com, "Cursor not placed correctly", col, &info, "*ETL");
}
}
AvidLogInfo(AVID, com, "Finished", 0, &info, "*T");
}
/*******************/
void test_scr_print(com, num_row, num_col)
int com;
int num_row;
int num_col;
/*******************/
{
int i, j, row, col;
char temp_buf[100];
long actual;
char capture[85];
int err, info;
char r;
/*
This will test the following commands...
ESC M which causes the terminal to send the character at
the cursor position to the host computer.
Test Description:
Within a nested for loop the ESC a rr R ccc C command is used
to position the cursor. Then a random character is written to
the screen. Printing a character will advance the cursor, therefore
the command ESC a rr R ccc C is executed to position the cursor
over the character just written. The ESC M command is then used
to verify the character was written correctly.
*/
AvidLogInfo(AVID, com, "Executing screen print test", 0, &info, "*T");
/* Clear the screen. */
clear_wyse_screen(com);
/* Shorten the test if requested. */
if ( !long_version)
num_col = 10;
/* Test each screen location. */
for (j=1; j<=num_col; j++) {
for (i=1; i<=num_row; i++) {
/* Move cursor to known location with ESC a rr R ccc C */
sprintf(temp_buf, "%sa%dR%dC", ESC_CODE, i, j);
if ((err = AvidSend(AVID, com, temp_buf, &info, "")) != ERR_SNF)
AvidLogInfo(AVID, com, "Problem sending string", err, &info, "");
/* Print a character. */
r = new_char();
sprintf(temp_buf, "%c", r);
if ((err = AvidSend(AVID, com, temp_buf, &info, "")) != ERR_SNF)
AvidLogInfo(AVID, com, "Problem sending string", err, &info, "*ETL");
/* Put the cursor back to the know location. */
sprintf(temp_buf, "%sa%dR%dC", ESC_CODE, i, j);
if ((err = AvidSend(AVID, com, temp_buf, &info, "")) != ERR_SNF)
AvidLogInfo(AVID, com, "Problem sending string", err, &info, "*ETL");
/* Get the character just placed. */
sprintf(temp_buf, ".s'%sM' +c'1'", ESC_CODE);
if ((err = AvidSendSearch(AVID, com, (long)10, (long)30, &info, temp_buf, (long *)&actual, capture)) != ERR_SNF)
AvidLogInfo(AVID, com, "Cursor not placed correctly", err, &info, "*ETL");
/* Fake errors for the demo. */
if ((j == 2) && (i == 10)) r = ' ';
if ((j == 4) && (i == 19)) r = ' ';
if ((j == 60) && (i == 12)) r = ' ';
/* Make sure the character we placed is there. */
if (capture[0] != r)
AvidLogInfo(AVID, com, "Incorrect character", capture[0], &info, "*ETL");
}
}
AvidLogInfo(AVID, com, "Finished", 0, &info, "*T");
}